3.5.54 \(\int \frac {1}{a+b \cos (c+d x)} \, dx\) [454]

Optimal. Leaf size=49 \[ \frac {2 \text {ArcTan}\left (\frac {\sqrt {a-b} \tan \left (\frac {1}{2} (c+d x)\right )}{\sqrt {a+b}}\right )}{\sqrt {a-b} \sqrt {a+b} d} \]

[Out]

2*arctan((a-b)^(1/2)*tan(1/2*d*x+1/2*c)/(a+b)^(1/2))/d/(a-b)^(1/2)/(a+b)^(1/2)

________________________________________________________________________________________

Rubi [A]
time = 0.02, antiderivative size = 49, normalized size of antiderivative = 1.00, number of steps used = 2, number of rules used = 2, integrand size = 12, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.167, Rules used = {2738, 211} \begin {gather*} \frac {2 \text {ArcTan}\left (\frac {\sqrt {a-b} \tan \left (\frac {1}{2} (c+d x)\right )}{\sqrt {a+b}}\right )}{d \sqrt {a-b} \sqrt {a+b}} \end {gather*}

Antiderivative was successfully verified.

[In]

Int[(a + b*Cos[c + d*x])^(-1),x]

[Out]

(2*ArcTan[(Sqrt[a - b]*Tan[(c + d*x)/2])/Sqrt[a + b]])/(Sqrt[a - b]*Sqrt[a + b]*d)

Rule 211

Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(Rt[a/b, 2]/a)*ArcTan[x/Rt[a/b, 2]], x] /; FreeQ[{a, b}, x]
&& PosQ[a/b]

Rule 2738

Int[((a_) + (b_.)*sin[Pi/2 + (c_.) + (d_.)*(x_)])^(-1), x_Symbol] :> With[{e = FreeFactors[Tan[(c + d*x)/2], x
]}, Dist[2*(e/d), Subst[Int[1/(a + b + (a - b)*e^2*x^2), x], x, Tan[(c + d*x)/2]/e], x]] /; FreeQ[{a, b, c, d}
, x] && NeQ[a^2 - b^2, 0]

Rubi steps

\begin {align*} \int \frac {1}{a+b \cos (c+d x)} \, dx &=\frac {2 \text {Subst}\left (\int \frac {1}{a+b+(a-b) x^2} \, dx,x,\tan \left (\frac {1}{2} (c+d x)\right )\right )}{d}\\ &=\frac {2 \tan ^{-1}\left (\frac {\sqrt {a-b} \tan \left (\frac {1}{2} (c+d x)\right )}{\sqrt {a+b}}\right )}{\sqrt {a-b} \sqrt {a+b} d}\\ \end {align*}

________________________________________________________________________________________

Mathematica [A]
time = 0.04, size = 48, normalized size = 0.98 \begin {gather*} -\frac {2 \tanh ^{-1}\left (\frac {(a-b) \tan \left (\frac {1}{2} (c+d x)\right )}{\sqrt {-a^2+b^2}}\right )}{\sqrt {-a^2+b^2} d} \end {gather*}

Antiderivative was successfully verified.

[In]

Integrate[(a + b*Cos[c + d*x])^(-1),x]

[Out]

(-2*ArcTanh[((a - b)*Tan[(c + d*x)/2])/Sqrt[-a^2 + b^2]])/(Sqrt[-a^2 + b^2]*d)

________________________________________________________________________________________

Maple [A]
time = 0.09, size = 44, normalized size = 0.90

method result size
derivativedivides \(\frac {2 \arctan \left (\frac {\tan \left (\frac {d x}{2}+\frac {c}{2}\right ) \left (a -b \right )}{\sqrt {\left (a -b \right ) \left (a +b \right )}}\right )}{d \sqrt {\left (a -b \right ) \left (a +b \right )}}\) \(44\)
default \(\frac {2 \arctan \left (\frac {\tan \left (\frac {d x}{2}+\frac {c}{2}\right ) \left (a -b \right )}{\sqrt {\left (a -b \right ) \left (a +b \right )}}\right )}{d \sqrt {\left (a -b \right ) \left (a +b \right )}}\) \(44\)
risch \(-\frac {\ln \left ({\mathrm e}^{i \left (d x +c \right )}+\frac {i a^{2}-i b^{2}+a \sqrt {-a^{2}+b^{2}}}{b \sqrt {-a^{2}+b^{2}}}\right )}{\sqrt {-a^{2}+b^{2}}\, d}+\frac {\ln \left ({\mathrm e}^{i \left (d x +c \right )}+\frac {-i a^{2}+i b^{2}+a \sqrt {-a^{2}+b^{2}}}{\sqrt {-a^{2}+b^{2}}\, b}\right )}{\sqrt {-a^{2}+b^{2}}\, d}\) \(137\)

Verification of antiderivative is not currently implemented for this CAS.

[In]

int(1/(a+b*cos(d*x+c)),x,method=_RETURNVERBOSE)

[Out]

2/d/((a-b)*(a+b))^(1/2)*arctan(tan(1/2*d*x+1/2*c)*(a-b)/((a-b)*(a+b))^(1/2))

________________________________________________________________________________________

Maxima [F(-2)]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \text {Exception raised: ValueError} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(1/(a+b*cos(d*x+c)),x, algorithm="maxima")

[Out]

Exception raised: ValueError >> Computation failed since Maxima requested additional constraints; using the 'a
ssume' command before evaluation *may* help (example of legal syntax is 'assume(4*b^2-4*a^2>0)', see `assume?`
 for more de

________________________________________________________________________________________

Fricas [A]
time = 0.45, size = 175, normalized size = 3.57 \begin {gather*} \left [-\frac {\sqrt {-a^{2} + b^{2}} \log \left (\frac {2 \, a b \cos \left (d x + c\right ) + {\left (2 \, a^{2} - b^{2}\right )} \cos \left (d x + c\right )^{2} + 2 \, \sqrt {-a^{2} + b^{2}} {\left (a \cos \left (d x + c\right ) + b\right )} \sin \left (d x + c\right ) - a^{2} + 2 \, b^{2}}{b^{2} \cos \left (d x + c\right )^{2} + 2 \, a b \cos \left (d x + c\right ) + a^{2}}\right )}{2 \, {\left (a^{2} - b^{2}\right )} d}, \frac {\arctan \left (-\frac {a \cos \left (d x + c\right ) + b}{\sqrt {a^{2} - b^{2}} \sin \left (d x + c\right )}\right )}{\sqrt {a^{2} - b^{2}} d}\right ] \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(1/(a+b*cos(d*x+c)),x, algorithm="fricas")

[Out]

[-1/2*sqrt(-a^2 + b^2)*log((2*a*b*cos(d*x + c) + (2*a^2 - b^2)*cos(d*x + c)^2 + 2*sqrt(-a^2 + b^2)*(a*cos(d*x
+ c) + b)*sin(d*x + c) - a^2 + 2*b^2)/(b^2*cos(d*x + c)^2 + 2*a*b*cos(d*x + c) + a^2))/((a^2 - b^2)*d), arctan
(-(a*cos(d*x + c) + b)/(sqrt(a^2 - b^2)*sin(d*x + c)))/(sqrt(a^2 - b^2)*d)]

________________________________________________________________________________________

Sympy [B] Leaf count of result is larger than twice the leaf count of optimal. 172 vs. \(2 (41) = 82\).
time = 2.21, size = 172, normalized size = 3.51 \begin {gather*} \begin {cases} \frac {\tilde {\infty } x}{\cos {\left (c \right )}} & \text {for}\: a = 0 \wedge b = 0 \wedge d = 0 \\\frac {1}{b d \tan {\left (\frac {c}{2} + \frac {d x}{2} \right )}} & \text {for}\: a = - b \\\frac {x}{a + b \cos {\left (c \right )}} & \text {for}\: d = 0 \\\frac {\tan {\left (\frac {c}{2} + \frac {d x}{2} \right )}}{b d} & \text {for}\: a = b \\\frac {\log {\left (- \sqrt {- \frac {a}{a - b} - \frac {b}{a - b}} + \tan {\left (\frac {c}{2} + \frac {d x}{2} \right )} \right )}}{a d \sqrt {- \frac {a}{a - b} - \frac {b}{a - b}} - b d \sqrt {- \frac {a}{a - b} - \frac {b}{a - b}}} - \frac {\log {\left (\sqrt {- \frac {a}{a - b} - \frac {b}{a - b}} + \tan {\left (\frac {c}{2} + \frac {d x}{2} \right )} \right )}}{a d \sqrt {- \frac {a}{a - b} - \frac {b}{a - b}} - b d \sqrt {- \frac {a}{a - b} - \frac {b}{a - b}}} & \text {otherwise} \end {cases} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(1/(a+b*cos(d*x+c)),x)

[Out]

Piecewise((zoo*x/cos(c), Eq(a, 0) & Eq(b, 0) & Eq(d, 0)), (1/(b*d*tan(c/2 + d*x/2)), Eq(a, -b)), (x/(a + b*cos
(c)), Eq(d, 0)), (tan(c/2 + d*x/2)/(b*d), Eq(a, b)), (log(-sqrt(-a/(a - b) - b/(a - b)) + tan(c/2 + d*x/2))/(a
*d*sqrt(-a/(a - b) - b/(a - b)) - b*d*sqrt(-a/(a - b) - b/(a - b))) - log(sqrt(-a/(a - b) - b/(a - b)) + tan(c
/2 + d*x/2))/(a*d*sqrt(-a/(a - b) - b/(a - b)) - b*d*sqrt(-a/(a - b) - b/(a - b))), True))

________________________________________________________________________________________

Giac [A]
time = 0.43, size = 78, normalized size = 1.59 \begin {gather*} -\frac {2 \, {\left (\pi \left \lfloor \frac {d x + c}{2 \, \pi } + \frac {1}{2} \right \rfloor \mathrm {sgn}\left (-2 \, a + 2 \, b\right ) + \arctan \left (-\frac {a \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )}{\sqrt {a^{2} - b^{2}}}\right )\right )}}{\sqrt {a^{2} - b^{2}} d} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(1/(a+b*cos(d*x+c)),x, algorithm="giac")

[Out]

-2*(pi*floor(1/2*(d*x + c)/pi + 1/2)*sgn(-2*a + 2*b) + arctan(-(a*tan(1/2*d*x + 1/2*c) - b*tan(1/2*d*x + 1/2*c
))/sqrt(a^2 - b^2)))/(sqrt(a^2 - b^2)*d)

________________________________________________________________________________________

Mupad [B]
time = 0.52, size = 43, normalized size = 0.88 \begin {gather*} \frac {2\,\mathrm {atan}\left (\frac {\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )\,\left (a-b\right )}{\sqrt {a^2-b^2}}\right )}{d\,\sqrt {a^2-b^2}} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

int(1/(a + b*cos(c + d*x)),x)

[Out]

(2*atan((tan(c/2 + (d*x)/2)*(a - b))/(a^2 - b^2)^(1/2)))/(d*(a^2 - b^2)^(1/2))

________________________________________________________________________________________